home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr51
/
postalbc.zip
/
POSTALBC.1
< prev
next >
Wrap
Text File
|
1993-04-17
|
3KB
|
64 lines
* postalbc.1 Version 1.0 Released 03-Jul-91
* DOC
* Routine:PostalBC
* Parameters:string zipcode
* either 5 digit or 9 digit with or without a "-"
* Usage:do PostalBC with "24551"
* Author:David G. Frankenbach, 804-237-2342, A-TBBS (FRNKNBCH)
* Description:This routine will print a Postal Bar Code using HP PCL
* This routine does no error checking on the zipcode passed in
* Revision:03-Jul-91 Initial Release
procedure PostalBC
parameter zip_code
private all_codes, bar_code, check, i, j, length, zip_digit
all_codes = "11000 00011 00101 00110 01001 01010 01100 10001 10010 10100"
bar_code = "1" && initial frame bar
length = len( zip_code ) && number of digits in zip
i = 1 && digit index
check = 0 && check digit
do while ( i <= length ) && while digits left in string
zip_digit = substr( zip_code, i, 1 ) && get this digit
if ( zip_digit <> "-" ) && ignore if -
j = val( zip_digit ) && convert to numeric
check = check + j && add to check digit
bar_code = bar_code + substr( all_codes, j * 6 + 1, 5 ) && concat this digit's bit pattern
endif
i = i + 1 && next digit
enddo
j = 10 - mod( check, 10 )
bar_code = bar_code + substr( all_codes, j * 6 + 1, 5 ) && concat check digit bit pattern
bar_code = bar_code + "1" && terminal frame bar
do PostalBC_Line with bar_code && print the bar code
return
* DOC
* Routine:PostalBC_Line
* Parameters:string bar_code
* Usage:internal routine, not called by user
* Description:Print the composed postal barcode line
* Revision:03-Jul-91 Initial Release
procedure PostalBC_Line
parameter bar_code
private i, length
length = len( bar_code ) && number of lines to print
i = 1 && first line
do while ( i <= length ) && while lines
if ( substr( bar_code, i, 1 ) = "1" ) && if long line
?? chr(27) + "*c5a40b0P"
else && short line
?? chr(27) + "*p+22Y" + chr(27) + "*c5a18b0P" + chr(27) + "*p-22Y"
endif
?? chr(27) + "*p+15X" && position of next line
i = i + 1 && next line
enddo
return